import request from '@/utils/request.ts'

/**
 * 用户登录
 * @param username 登录用户
 * @param password 登录密码
 * @param code     验证码
 * @author WarmMeaning
 * @date 2025-01-02
 */
export function login(username: string, password: string, code: string) {
  const data = {username, password, code};
  return request({
    url: '/login',
    headers: {
      isToken: false,
      repeatSubmit: false,
    },
    method: 'POST',
    data: data
  })
}

/**
 * 用户登出
 * @author WarmMeaning
 * @date 2025-01-02
 */
export function logout() {
  return request({url: '/logout', method: 'POST'})
}


/**
 * 用户注册
 * @author WarmMeaning
 * @date 2025-01-02
 */
export function register(data: object) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'POST',
    data: data
  })
}

/**
 * 获取验证码
 * @author WarmMeaning
 * @date 2025-01-02
 */
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    headers: {isToken: false},
    method: 'GET',
    timeout: 20000
  })
}
